
#include "Scok.hpp"
#include "json.hpp"
#include <stdlib.h>

int main()
{
    Sock sock;
    sock.Socket();
    sock.Connect("127.0.0.1", 8085);
    srand(0);
    char arr[] = "+-*/";
    //Json::Value root;
    while(true)
    {
        Json::Value root;
        int x = rand() % 10;
        int y = rand() % 10;
        string op(1, arr[rand() % 3]);
        root["x"] = x;
        root["y"] = y;
        root["op"] = op;
        string s = serialize(root);

        write(sock.Fd(), s.c_str(), s.size());

        char buffer[1024];
        read(sock.Fd(), buffer, sizeof(buffer));
        string ss(buffer);
        std::cout << ss << endl;
    }
    return 0;
}